#pragma once

typedef void * HANDLE;

namespace mswin {

// object of the class locks directory for exclusive use during its lifetime
class dir_lock {
public:
	dir_lock() : handle_(0) 
		{ }
	dir_lock(const char * path) : handle_(0) 
		{ lock(path); }
	~dir_lock()
		{ unlock(); }
	/// return true if locking was successfull
	bool lock(const char * path);
	void unlock();
	bool is_locked() const
		{ return handle_ != 0; }
private:
	HANDLE handle_;
};

} //namespace mswin
